<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>父亲</p>
        <span>礼物：{{liwu}}</span>
        <p>好大儿</p>
        <child @parent="ji"></child>
    </div>
    <template id="child">
        <div>
            <button @click='click1'>给爸爸</button>
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        let child={
            template:'#child',
            data () {
                return {
                    watch:'jg1',
                }
            },
            methods: {
                click1(){
                    this.$emit('parent',this.watch);
                }
            }
        };
        new Vue({
            el:'#app',
            components: {
                child,
            },
            data () {
                return {
                    liwu:'',
                }
            },
            methods: {
                ji(val){
                    this.liwu=val;
                }
            }
        })
    </script>
</body>
</html>